<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字符串</title>
</head>
<script>
    var str = 'hhhh';
    console.log(str.length);
    console.log('-----------');
    //  所有o出现的位置和次数
    var str2 = 'abcoefoxyozzopp';

    function find(str, ato) {
        var ciShu = 0;
        var idx = str.indexOf(ato);
        while (idx !== -1) {
            ciShu++;
            console.log(idx);
            idx = str.indexOf(ato, idx + 1);
        }

        return ciShu;

    }
    console.log(find(str2, 'o'));
    console.log('-----------');

    var str3 = 'andy';
    console.log(str3[0]);
    console.log('-----------');
    for (var i = 0; i < str.length; i++) {
        console.log(str3.charAt(i));
        console.log(str3.charCodeAt(i));

    }







</script>

<body>

</body>

</html>